function [position,velocity,num]=readText( dirName,fileNum,dataMode )
% input the txt file's name to get the matrix of position, velocity and the number of birds
% dataMode = ...
% 1: normal data
% 2: flow field data
fileArray = dir(dirName);
if dataMode == 1 
    
    nameCat = [dirName,'\',fileArray(fileNum+3).name]; % "3" because of '.  ..  parameter'
    A = textread(nameCat,'%f'); % temporary matrix to extract data
    siz = size(A);
    num = siz(1)/6;
    position = zeros(num,3);
    velocity = zeros(num,3);
    for i= 1 : num
        position(i, :) = [A(6*(i-1)+1),A(6*(i-1)+2),A(6*(i-1)+3)];
        velocity(i, :) = [A(6*(i-1)+4),A(6*(i-1)+5),A(6*(i-1)+6)];
    end
    % velocity = velocity +10;


elseif dataMode == 2 
    
    nameCat = [dirName,'\',fileArray(fileNum+2).name]; % "2" because of '.  .. '
    [x, y, u, v, ~, ~, ~, ~] = fluere_dat2mtx(nameCat);

    num = 150; % the number of points picked
    siz = size(x);
    num0 = siz(1)*siz(2);
    xx = reshape(x,num0,1);
    yy = reshape(y,num0,1);
    uu = reshape(u,num0,1);
    vv = reshape(v,num0,1);
    position = cat(2,xx,yy,zeros(num0,1));
    position = position(end-num+1:end,:);
    velocity = cat(2,uu,vv,zeros(num0,1));
    velocity = velocity(end-num+1:end,:);

else 
    error('undefined Mode!')
end
for i = 1 : num
    velocity(i,:) = velocity(i,:) / norm(velocity(i,:));
end % normalization
end 